import { useState, useEffect } from 'react';
import { fetchProductProjectList } from '../Employee/service';

// 产品线和项目组信息
const useProductProjectList = query => {
    const [data, setData] = useState([]);
    const [loading, setLoading] = useState(true);

    const fetchData = async () => {
        setLoading(true);
        const { data: rowData, code } = (await fetchProductProjectList(query)) || {};
        if (code === 10000) {
            setData(rowData);
        }
        setLoading(false);
    };

    useEffect(() => {
        fetchData();
    }, [query]);

    return [loading, data];
};

export default useProductProjectList;
